﻿@model FortuneCat.WebUI.Models.SaveBalanceViewModel

<script type="text/javascript">
    $(function () {
        $("#receiptOrPayment").buttonset();
        $("#users").buttonset();
        $("#BalanceDate")
        .datepicker($.datepicker.regional["zh-CN"])
        .datepicker();
    });
</script>

@Html.ValidationSummary()

@using (Html.BeginForm("Save", "Home", FormMethod.Post, new { id = "saveBalanceForm" })) { 
    @Html.HiddenFor(x => x.Id)
    <table border="0" cellpadding="0" cellspacing="0" class="form">
        <tr>
            <th>类型:</th>
            <td>
                <div id="receiptOrPayment">
                    <input type="radio" id="IsReceipt" name="IsReceipt" value="true" @(Model.Id == 0 ? "checked='checked'" : (Model.IsReceipt ? "checked='checked'" : null)) /><label for="IsReceipt">收入</label>
                    <input type="radio" id="IsPayment" name="IsReceipt" value="false" @(Model.Id == 0 ? null : (Model.IsReceipt ? null : "checked='checked'")) /><label for="IsPayment">支出</label>
                </div>
            </td>
        </tr>
        <tr>
            <th>@Html.LabelFor(x => x.BalanceDate)</th>
            <td><input type="text" id="BalanceDate" name="BalanceDate" value="@Model.BalanceDate.ToString("yyyy-M-d")" class="textbox" readonly="readonly" /></td>
        </tr>
        <tr>
            <th>@Html.LabelFor(x => x.Amount)</th>
            <td><input type="text" name="Amount" value="@Model.Amount.ToString("F2")" class="textbox" /></td>
        </tr>
        <tr>
            <th>@Html.LabelFor(x => x.Reason)</th>
            <td>@Html.TextBoxFor(x => x.Reason, new { @class = "textbox" })</td>
        </tr>
        <tr>
            <!--th>@Html.LabelFor(x => x.UserId)</th>
            <td>@Html.DropDownListFor(x => x.UserId, Model.Users)</td-->
            <th>收支人:</th>
            <td>
                <div id="users">
                @foreach (var user in Model.Users) { 
                    <input type="radio" id="user@(user.Value)" name="UserId" value="@user.Value" @(user.Selected ? "checked='checked'" : null)) /><label for="user@(user.Value)">@user.Text</label>
                }
                </div>
            </td>
        </tr>
    </table>
}